package gjj.gui;

import gjj.App;

import javax.swing.*;
import java.awt.*;

public abstract class OpenCVSupportedGui extends JFrame {
    private static final String ROOT = App.class.getResource("/").getPath();

    static {
        System.load(ROOT + "libopencv_java4120.dylib");
    }

    protected final int IMAGE_WIDTH = 1200;
    protected final int IMAGE_HEIGHT = 900;

    protected final int WINDOW_WIDTH = 1200;
    protected final int WINDOW_HEIGHT = 980;

    protected abstract void init();

    public OpenCVSupportedGui() throws HeadlessException {
        Toolkit toolkit = Toolkit.getDefaultToolkit();
        Dimension screenSize = toolkit.getScreenSize();
        double windowWidth = screenSize.getWidth(), windowHeight = screenSize.getHeight();
        this.setIconImage(new ImageIcon(App.class.getResource("/jcv_icon.png")).getImage());
        this.setSize(WINDOW_WIDTH,  WINDOW_HEIGHT);
        this.setResizable(false);
        this.setLocation((int) (windowWidth - IMAGE_WIDTH) / 2, (int) (windowHeight - IMAGE_HEIGHT) / 2);
        this.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
        init();
    }
}
